﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;
namespace GUI
{
    public partial class ThongKeSoLuongHanhKhachTheoTuyen : Form
    {
        public ThongKeSoLuongHanhKhachTheoTuyen()
        {
            InitializeComponent();
        }
        public void ShowMaster()
        {
            int maTuyen = int.Parse(cbTenTuyen.SelectedValue.ToString());

            this.dgvDanhSach.AutoGenerateColumns = false;
            this.dgvDanhSach.DataSource = THONGKEHANHKHACH_BUS.SelectThongKeHanhKhach(maTuyen);
            tbSoHK.Text = this.dgvDanhSach.RowCount.ToString();
        }
        private void cbTenTuyen_SelectedIndexChanged(object sender, EventArgs e)
        {
            cbTenTuyen.ValueMember = "MaTuyenDL";
            //cbTenTuyen.DisplayMember = "TenTuyenDL";
            ShowMaster();
        }

        private void btThongKe_Click(object sender, EventArgs e)
        {
            ShowMaster();
        }

        private void btThoat_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Bạn Thật Sự Muốn Thoát?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dr == DialogResult.Yes)
            {
                this.Close();
            }
        }

        private void ThongKeSoLuongHanhKhachTheoTuyen_Load(object sender, EventArgs e)
        {
            cbTenTuyen.DataSource = TUYENDL_BUS.SelectTuyenDuLichsAll();
            cbTenTuyen.ValueMember = "MaTuyenDL";
            cbTenTuyen.DisplayMember = "TenTuyenDL";
            ShowMaster();
        }
    }
}
